package com.heyqing.topic.FizzBuzz_0412;

import java.util.ArrayList;
import java.util.List;

/**
 * ClassName:FizzBuzz
 * Package:com.heyqing.topic.FizzBuzz_0412
 * Description:
 *
 * @Date:2024/9/29
 * @Author:Heyqing
 */
public class FizzBuzz {
    public List<String> fizzBuzz(int n) {
        List<String> res = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            if (i % 3 == 0 || i % 5 == 0) {
                if (i % 3 == 0 && i % 5 == 0) {
                    res.add("FizzBuzz");
                    continue;
                }
                if (i % 3 == 0) {
                    res.add("Fizz");
                    continue;
                }
                res.add("Buzz");
            } else {
                res.add(String.valueOf(i));
            }
        }
        return res;
    }
}
